﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace leodesigner
{
    public partial class PropertyView : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        public PropertyView()
        {
            InitializeComponent();
        }

        public void Fill(CodersLab.Windows.Controls.NodesCollection selectedNodes)
        {
				 if (selectedNodes==null)
				 {
                     
					 propertyGrid.SelectedObjects=null;
					 return;
				 }

				 ArrayList selectedBagList=new ArrayList();

				 for (int n=0; n<selectedNodes.Count; ++n)
				 {
                     interop.EntityTreeNode node = selectedNodes[n] as interop.EntityTreeNode;
					 if (node.bag!=null)
						 selectedBagList.Add(node.bag);
				 }

				 if (selectedNodes.Count==1)
				 {
                     interop.EntityTreeNode node = (interop.EntityTreeNode)selectedNodes[0];
					 this.TabText="Properties - "+node.Text;
				 }
				 else
				 {
					 this.TabText="Properties - "+selectedNodes.Count.ToString()+" objects selected";
				 }

				 propertyGrid.SelectedObjects=selectedBagList.ToArray();

        }

        private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
		if (e.ChangedItem.Label=="name")
		{
            designer.Designer.scenetreeview.nodeNameChanged();
		}

        }
    }
}
